<?php

namespace app\index\service;

use app\index\dao\MemberDao;
use app\index\model\UM as UM;
use think\exception\ValidateException;

/**
 * Class MemberSvipAgreeService
 * @package app\index\service
 */
class MemberSvipAgreeService
{
    // dao
    private MemberDao $memberDao;

    public function __construct(MemberDao $memberDao)
    {
        $this->memberDao = $memberDao;
    }

    /**
     * 更新
     * @param UM $user
     * @param array $params
     * @return void
     */
    public function modify(UM $user, array $params): void
    {
        if ($user->svipAgree == 1) {
            throw new ValidateException('您已经同意了');
        }

        $user->svipAgree = 1;
        $user->svipAgreeTime = time();
        $user->save();
    }

}
